package com.syg.controller;

import com.syg.service.RetryService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author ps
 */
@RestController
public class RetryController {

    @Resource
    RetryService retryService;

    AtomicInteger ai = new AtomicInteger();

    @GetMapping("/retry")
    public int testRetry(Integer code) {
        try {
            System.out.println(retryService.testRetry(code));
            return retryService.testRetry(code);
        } catch (Exception e) {
            System.out.println(ai.incrementAndGet());
        }
        return 0;
    }
}
